import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const router = new Router({
    mode: 'history',
    routes: [
        {
            path: '/',
            component: () => import('@/components/layout'),
            children: [
                {
                    path: '',
                    component: () => import('@/views/auth/login')
                }
            ]

        },
        {
            path: '/refresh',
            component: () => import('@/components/layout'),
            children: [
                {
                    path: '',
                    component: () => import('@/views/auth/refresh')
                }
            ]

        }

    ]
});
import store from '@/store'

//路由拦截器 每次路由跳转都经过这个拦截器
router.beforeEach((to,from,next) =>{
    if(to.path === '/logout'){
        console.log('拦截到logout  执行了Logout方法')
        //退出操作
        store.dispatch('userLogout',to.query.redirectURL)
    }else{
        next()
    }
})

export default router
